package com.ruoyi.collect.service.impl;

import com.ruoyi.collect.domain.CollectCourseVideos;
import com.ruoyi.collect.mapper.CollectCourseVideosMapper;
import com.ruoyi.collect.service.ICourseVideosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课程视频Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-19
 */
@Service("collectCourseVideosService")
public class CourseVideosServiceImpl implements ICourseVideosService
{
    @Autowired
    private CollectCourseVideosMapper courseVideosMapper;

    /**
     * 查询课程视频
     * 
     * @param id 课程视频主键
     * @return 课程视频
     */
    @Override
    public CollectCourseVideos selectCourseVideosById(Long id)
    {
        return courseVideosMapper.selectCourseVideosById(id);
    }

    /**
     * 查询课程视频列表
     * 
     * @param courseVideos 课程视频
     * @return 课程视频集合
     */
    @Override
    public List<CollectCourseVideos> selectCourseVideosList(CollectCourseVideos courseVideos)
    {
        return courseVideosMapper.selectCourseVideosList(courseVideos);
    }

    /**
     * 根据课程ID查询视频列表
     * 
     * @param courseId 课程ID
     * @return 课程视频集合
     */
    @Override
    public List<CollectCourseVideos> selectCourseVideosByCourseId(Long courseId)
    {
        return courseVideosMapper.selectCourseVideosByCourseId(courseId);
    }

    /**
     * 新增课程视频
     * 
     * @param courseVideos 课程视频
     * @return 结果
     */
    @Override
    public int insertCourseVideos(CollectCourseVideos courseVideos)
    {
        // 设置默认值
        if (courseVideos.getDel() == null) {
            courseVideos.setDel(0);
        }
        return courseVideosMapper.insertCourseVideos(courseVideos);
    }

    /**
     * 批量新增课程视频
     * 
     * @param courseVideosList 课程视频列表
     * @return 结果
     */
    @Override
    public int batchInsertCourseVideos(List<CollectCourseVideos> courseVideosList)
    {
        // 设置默认值
        for (CollectCourseVideos courseVideos : courseVideosList) {
            if (courseVideos.getDel() == null) {
                courseVideos.setDel(0);
            }
        }
        return courseVideosMapper.batchInsertCourseVideos(courseVideosList);
    }

    /**
     * 修改课程视频
     * 
     * @param courseVideos 课程视频
     * @return 结果
     */
    @Override
    public int updateCourseVideos(CollectCourseVideos courseVideos)
    {
        return courseVideosMapper.updateCourseVideos(courseVideos);
    }

    /**
     * 删除课程视频
     * 
     * @param id 课程视频主键
     * @return 结果
     */
    @Override
    public int deleteCourseVideosById(Long id)
    {
        return courseVideosMapper.deleteCourseVideosById(id);
    }
    
    /**
     * 根据课程ID删除视频
     * 
     * @param courseId 课程ID
     * @return 结果
     */
    @Override
    public int deleteCourseVideosByCourseId(Long courseId)
    {
        return courseVideosMapper.deleteCourseVideosByCourseId(courseId);
    }

    /**
     * 批量删除课程视频
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int deleteCourseVideosByIds(Long[] ids)
    {
        return courseVideosMapper.deleteCourseVideosByIds(ids);
    }
}
